package io.renren.modules.diycake.controller;

import io.renren.common.utils.R;
import io.renren.modules.diycake.service.OssService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/Oss")
@CrossOrigin
@Api(value = "上传图片",tags = "上传图片-API")
public class OssController {
  @Autowired
  private OssService ossService;

  @PostMapping("upload")
  public R uploadOssFile(MultipartFile file) {
    String url = ossService.uploadFileAvatar(file);
    return R.ok().put("url",url);
  }

  @PostMapping("upload/photo")
  public R uploadOssPhoto(MultipartFile file) {
    String url = ossService.uploadFilePhoto(file);
    return R.ok().put("url",url);
  }

  @PostMapping("upload/{vedioId}")
  public R uploadOssVedioId(MultipartFile file,@PathVariable Integer vedioId) {
    String url = ossService.uploadOssVedioId(file,vedioId);
    return R.ok().put("url",url);
  }

}
